<%

Dim Err_sendMail	'Hold sending mail error message

'Procedure name		: sendMail
'Action				: send an email
'Arguments			: - strFromName	: sender name
'					  - strFrom		: sender email
'					  - strTo		: receiver
'					  - strSubject	: email subject
'					  - strBoby		: email body
'					  - blnHTML		: 1 for HTML format and 0 for plain text
'Return				: return True if sending succeed
Private Function sendMail(strTo, strCC, strSubject, strBody, blnHTML)
	'On Error Resume Next
	
	'Initialize
	sendMail = False
	
	'Check for From and sender field
	
	If strTo <> "" Then
		
		Dim cdoMail		'cdoMail object 
		Dim cdoConf		'cdoConfiguration object
			
		Set cdoMail = Server.CreateObject("CDO.Message")
		Set cdoConf = Server.CreateObject("CDO.Configuration")
		
		
		' Configure mail option
		With cdoConf
			
			' Specify the authentication mechanism to basic (clear-text) authentication cdoBasic = 1
			'.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
			        	
			'SMTP Server username
			'.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "vuthy@indochinaresearch.com"
			'.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "chanmann@indochinaresearch.com"
			
			'SMTP Server password
			'.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "chinv"
			'.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "irlclim"
			
			
			' If using remote server the vaule must be 2
			.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
			
			'.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.secureserver.net"
			.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "online.com.kh"
			
			.Fields("http://schemas.microsoft.com/cdo/configuration/stmpserverport") = 25
			
			'.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
			
			.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
			
			.Fields.Update
		End With
		
		'Update the CDOSYS Configuration
		Set cdoMail.Configuration = cdoConf
		
		With cdoMail
			'Who the e-mail is from
			.From = "IRL <chanmann@indochinaresearch.com>"
	
			'Who the e-mail is sent to
			.To = strTo			
			
			'CC
			If strCC <> "" Then
				.CC = strCC
			End if
	
			'The subject of the e-mail
			.Subject = strSubject
	
			'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
			If blnHTML Then
			
				.HTMLBody = strBody
				
			Else
			
				.TextBody = strBody
				
			End if
			
			'myMail.AddAttachment "c:\mydocuments\test.txt"

	
			'Send the e-mail
			.Send
			
	
		End with
	
		
		'Close the server mail object
		Set cdoMail = Nothing
		Set cdoConf = Nothing
		
	End if
	
	
	'Setting error reporting
	If Err.Number = 0 Then					
		sendMail = True
	Else
		Err_sendMail = Err.Description
		Err.Clear '= On Error GoTo 0
	End if
	
	'Response.Write(sendMail): Response.End()
	
End Function

%>